package com.bank.um.service.Impl;

import com.bank.entity.Member;
import com.bank.entity.User;
import com.bank.um.mapper.MemberMapper;
import com.bank.um.mapper.UserMapper;
import com.bank.um.service.UserService;
import com.bank.utils.CookieUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * @author: Lixy
 * @email: 1908598362@qq.com
 * @date: 2021/12/31 星期五 20:33
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
    @Autowired
    private UserMapper userMapper;

    @Transactional
    public List<User> listAll() {
        List<User> userList = userMapper.selectList(null);
        return userList;
    }

    @Transactional
    public int addUser(String name, Long memcardnum,String password) {
        User user = new User();
        user.setName(name);
        user.setUsrCardnum(memcardnum);
        user.setPassword(password);
        int row = userMapper.insert(user);
        return row;
    }

    public User SelectById(String name, String password) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("name", name);
        queryWrapper.eq("password", password);
        User user = userMapper.selectOne(queryWrapper);
        return user;
    }

}
